package io.gitee.hechenl.fastiotreport.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ProductUnit {

    TOBACCO_CASE(1, "箱"),
    TOBACCO_LEAF_TON(2, "吨烟丝"),
    TOBACCO_LEAF_KILOGRAM(3, "千克烟丝");

    private final Integer value;
    private final String desc;

    ProductUnit(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static ProductUnit getByValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (ProductUnit type : values()) {
            if (Objects.equals(type.getValue(), value)) {
                return type;
            }
        }
        return null;
    }
}
